$(function(){
	if(LGlobal.canTouch){
		LGlobal.stageScale = LStageScaleMode.EXACT_FIT;
		LSystem.screen(LStage.FULL_SCREEN);
	}
	LGlobal.align = LStageAlign.TOP_MIDDLE;
	LGlobal.stageScale = LStageScaleMode.NO_SCALE;
	LSystem.screen(LStage.FULL_SCREEN);
	LGlobal.preventDefault=true;//禁止页面滚屏和原生表单啥的，设为false就给解开了

	var hei=$(this).innerHeight();
	init(30,"mylegend",640,hei,main);
});

var stageW,stageH;

var imgData=new Array(
	{name:'logo',path:'./images/logo.png'},
	{name:'kuang',path:'./images/kuang.png'},
	{name:'nav',path:'./images/nav.png'},
	{name:'yuan',path:'./images/yuan.png'},
	{name:'bg0',path:'./images/bg0.jpg'},
	{name:'car0',path:'./images/car0.png'},
	{name:'title',path:'./images/title.png'},

	{name:'car1',path:'./images/car1.png'},
	{name:'infor',path:'./images/infor.png'},
	{name:'jingliang',path:'./images/jingliang.png'},
	{name:'quanxin',path:'./images/quanxin.png'},
	{name:'p1_p0',path:'./images/p1_p0.png'},
	{name:'p1_p1',path:'./images/p1_p1.png'},
	{name:'p1_p12',path:'./images/p1_p12.png'},
	{name:'p1_p2',path:'./images/p1_p2.png'},

	{name:'bg1',path:'./images/bg1.jpg'},
	{name:'bird',path:'./images/bird.png'},
	{name:'car2',path:'./images/car2.png'},
	{name:'home',path:'./images/home.png'},
	{name:'s1_z1',path:'./images/s1_z1.png'},
	{name:'s1_z2',path:'./images/s1_z2.png'},

	{name:'car3',path:'./images/car3.png'},
	{name:'s2_z1',path:'./images/s2_z1.png'},
	{name:'s2_z2',path:'./images/s2_z2.png'}
);

var datalist=[];

var loading,logo,game;
function main(){
	baseLayer = new LSprite();
	addChild(baseLayer);
	
	stageW=$(this).innerWidth();
	stageH=$(this).innerHeight();

	//初始化loading
	loading=new Loading();
	loading.init(imgData,false);

	loading.progress=myProgress;
	loading.complete=myComplete;

	loading.start();
}

function myComplete(e){
	datalist=e;
	myInit();
}

function myProgress(e){
	console.log(e);
}


function myInit(){
	game=new Game();
	baseLayer.addChild(game);

	logo=new LBitmap(new LBitmapData(datalist['logo']));
	baseLayer.addChild(logo);
	logo.x=stageW-logo.getWidth()-50;
	logo.y=50;
}